<?php

define("DEBUG", true);

function pretty_die($text){
	if(DEBUG)
		die($text);
	else
		die("Oops. Tell the admin about this.");
}

function db_close(){
	global $db;
	$db->close();
}

function db_get_row($result){
	return $result-> fetch_assoc();
}

function db_query($query)
{
	global $db;
	$result = $db->query($query);
	if (!$result) 
		pretty_die('Database Error: ' . mysqli_error($db));
	return $result;
}

function db_escape($input){
	global $db;
	return $db->real_escape_string($input);
}

$db = new mysqli('localhost', 'root', '', 'watch');

/*$db->mysql_set_charset("utf8");*/

if (mysqli_connect_error()) {
	pretty_die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
}


?>
